package com.yanqu.road.server.cmd.cookboy.process3;

import com.yanqu.road.pb.cookboy.CookBoyProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.cookboy.CookBoyMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_COOK_BOY3_JOIN_BANQUET, desc = "参加宴会")
public class CookBoy3JoinBanquetCmd extends AbstractCommand {

	int activityId;
	int banquetId;
	long homeUserId;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		CookBoyProto.CookBoy3JoinBanquetReqMsg reqMsg = CookBoyProto.CookBoy3JoinBanquetReqMsg.parseFrom(packet.getBytes());
		activityId = reqMsg.getActivityId();
		homeUserId = reqMsg.getUserId();
		banquetId = reqMsg.getBanquetId();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		//加入宴会没有限制
		ret = CookBoyMgr.sendJoinBanquetMsg(activityId,player.getUserId(),homeUserId,banquetId);
	}

	@Override
	public void sendData(GamePlayer player) {
		if(ret != 0){
			CookBoyProto.CookBoy2JoinTableRespMsg.Builder respMsg = CookBoyProto.CookBoy2JoinTableRespMsg.newBuilder();
			respMsg.setRet(ret);
			player.sendPacket(Protocol.U_COOK_BOY3_JOIN_BANQUET, respMsg);
		}
	}
}
